$(document).ready(function() {
    $('#submit').click(function() {
        $.mobile.showPageLoadingMsg();
        var cityname = $('#cityname').val();
        var url = 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%20in%20(%0Aselect%20id%20from%20weather.search%20where%20query%3D%22' + cityname + '%22%0A)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=?';
        $.getJSON(url, function(data) {
            init(data.query.results.channel);
            $.mobile.changePage('#weather');
            $.mobile.hidePageLoadingMsg();
        })
    })
})

function init(data){
    $('#weather h1').html(data.title);
    $('#wDescription').html(data.item.description);
}